﻿Imports NENAData.Factory
Imports NENAData.LINQ
Imports NENAData.NENAMember.Account
Imports System.Linq
Imports NENAData.Payments

Partial Public Class AdminProcessAccount
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Private Sub ProcessAccount()
        Dim oActivate As Activate = New Activate
        'oActivate.MembershipAccount(intAffiliateID, intMemberID, True, NENAData.Payments.NENAPayments.PaidBy.Cheque, 0)

    End Sub

    Protected Sub btnCheck_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnCheck.Click

    End Sub

    Protected Sub btnPayPal_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnPayPal.Click
        Dim lmembers
        lmembers = GetMembers()

        Dim oTPayment As TransactionPayment = New TransactionPayment

        Dim m As Member

        Dim oActivate As Activate = New Activate()
        Dim oPayment As NENAData.Payments.NENAPayments = New NENAPayments
        For Each m In lmembers

            Response.Write("<br />member fname: " & m.FirstName & " member_id: " & m.Member_ID & " paid status: " & m.Paid)
            oTPayment = oPayment.GetTransactionPayment(2, m.Member_ID)
            Response.Write(" payment: " & oTPayment.TransactionPaymentID)
            'oActivate.MembershipAccount(m.Affiliate_ID, m.Member_ID, True, NENAPayments.PaidBy.PayPal, oTPayment.TransactionPaymentID)

        Next



    End Sub

    Private Function GetMembershipDB() As MembershipDataContext

        Dim x = New SQLMembership()
        Return x.GetMembershipDB()
    End Function

    Private Function GetMembers() As List(Of Member)
        Dim db As MembershipDataContext = GetMembershipDB()

        Dim listMembers = (From m In db.Members _
                           Join tp In db.TransactionPayments On m.Member_ID Equals tp.Member_ID _
                       Where m.Paid.Contains("N") And tp.TransactionCompleted _
                          Select m).ToList()

        Return listMembers
    End Function

End Class